{set:
	$myCartObj  = new Cart();
	$myCartInfo = $myCartObj->getMyCart();
	$siteConfig = new Config("site_config");
	$callback   = IReq::get('callback') ? urlencode(IFilter::act(IReq::get('callback'),'url')) : '';
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>{echo:$siteConfig->name}</title>
	<link type="image/x-icon" href="favicon.ico" rel="icon">
	<link rel="stylesheet" href="{skin:css/index.css}" />
	{js:jquery}
	{js:form}
	{js:validate}
	{js:dialog}
	{js:artTemplate}
	<script type='text/javascript' src="{theme:javascript/common.js}"></script>
	<script type='text/javascript' src='{theme:javascript/site.js}'></script>
	{set:$sonline = new Sonline();$sonline->show($siteConfig->phone,$siteConfig->service_online);}
</head>
<body class="index">
<div class="container">
	<div class="header">
		<h1 class="logo"><a title="{echo:$siteConfig->name}" style="background:url({skin:images/front/logo.gif});" href="{url:}">{echo:$siteConfig->name}</a></h1>
		<ul class="shortcut">
			<li class="first"><a href="{url:/ucenter/index}">我的账户</a></li>
			<li><a href="{url:/ucenter/order}">我的订单</a></li>
			<li><a href="{url:/simple/seller}">申请开店</a></li>
			<li><a href="{url:/seller/index}">商家管理</a></li>
			<li class='last'><a href="{url:/site/help_list}">使用帮助</a></li>
		</ul>
		<p class="loginfo">
			{if:$this->user}
			{echo:$this->user['username']}您好，欢迎您来到{echo:$siteConfig->name}购物！[<a href="{url:/simple/logout}" class="reg">安全退出</a>]
			{else:}
			[<a href="{url:/simple/login?callback=$callback}">登录</a><a class="reg" href="{url:/simple/reg?callback=$callback}">免费注册</a>]
			{/if}
		</p>
	</div>
	<div class="navbar">
		<ul>
			<li><a href="{url:/site/index}">首页</a></li>
			{foreach:items=Api::run('getGuideList')}
			<li><a href="{url:$item[link]}">{$item['name']}<span> </span></a></li>
			{/foreach}
		</ul>

		<div class="mycart">
			<dl>
				<dt><a href="{url:/simple/cart}">购物车<b name="mycart_count">{$myCartInfo['count']}</b>件</a></dt>
				<dd><a href="{url:/simple/cart}">去结算</a></dd>
			</dl>

			<!--购物车浮动div 开始-->
			<div class="shopping" id='div_mycart' style='display:none;'>
			</div>
			<!--购物车浮动div 结束-->

			<!--购物车模板 开始-->
			<script type='text/html' id='cartTemplete'>
			<dl class="cartlist">
				<%for(var item in goodsData){%>
				<%var data = goodsData[item]%>
				<dd id="site_cart_dd_<%=item%>">
					<div class="pic f_l"><img width="55" height="55" src="{webroot:<%=data['img']%>}"></div>
					<h3 class="title f_l"><a href="{url:/site/products/id/<%=data['goods_id']%>}"><%=data['name']%></a></h3>
					<div class="price f_r t_r">
						<b class="block">￥<%=data['sell_price']%> x <%=data['count']%></b>
						<input class="del" type="button" value="删除" onclick="removeCart('{url:/simple/removeCart}','<%=data['id']%>','<%=data['type']%>');$('#site_cart_dd_<%=item%>').hide('slow');" />
					</div>
				</dd>
				<%}%>

				<dd class="static"><span>共<b name="mycart_count"><%=goodsCount%></b>件商品</span>金额总计：<b name="mycart_sum">￥<%=goodsSum%></b></dd>

				<%if(goodsData){%>
				<dd class="static">
					{if:ISafe::get('user_id')}
					<a class="f_l" href="javascript:void(0)" onclick="deposit_ajax('{url:/simple/deposit_cart_set}');">寄存购物车>></a>
					{/if}
					<label class="btn_orange"><input type="button" value="去购物车结算" onclick="window.location.href='{url:/simple/cart}';" /></label>
				</dd>
				<%}%>
			</dl>
			</script>
			<!--购物车模板 结束-->
		</div>
	</div>

	<div class="searchbar">
		<div class="allsort">
			<a href="javascript:void(0);">全部商品分类</a>

			<!--总的商品分类-开始-->
			<ul class="sortlist" id='div_allsort' style='display:none'>
				{foreach:items=Api::run('getCategoryListTop')  item=$first }
				<li>
					<h2><a href="{url:/site/pro_list/cat/$first[id]}">{$first['name']}</a></h2>

					<!--商品分类 浮动div 开始-->
					<div class="sublist" style='display:none'>
						<div class="items">
							<strong>选择分类</strong>
							{foreach:items=Api::run('getCategoryByParentid',array('#parent_id#',$first['id']))  item=$second}
							<dl class="category selected">
								<dt>
									<a href="{url:/site/pro_list/cat/$second[id]}">{$second['name']}</a>
								</dt>

								<dd>
									{foreach:items=Api::run('getCategoryByParentid',array('#parent_id#',$second['id']))  item=$third}
									<a href="{url:/site/pro_list/cat/$third[id]}">{$third['name']}</a>|
									{/foreach}
								</dd>
							</dl>
							{/foreach}
						</div>
					</div>
					<!--商品分类 浮动div 结束-->
				</li>
				{/foreach}
			</ul>
			<!--总的商品分类-结束-->
		</div>

		<div class="searchbox">
			<form method='get' action='{url:/}'>
				<input type='hidden' name='controller' value='site' />
				<input type='hidden' name='action' value='search_list' />
				<input class="text" type="text" name='word' autocomplete="off" value="输入关键字..." />
				<input class="btn" type="submit" value="商品搜索" onclick="checkInput('word','输入关键字...');" />
			</form>

			<!--自动完成div 开始-->
			<ul class="auto_list" style='display:none'></ul>
			<!--自动完成div 开始-->

		</div>
		<div class="hotwords">热门搜索：
			{foreach:items=Api::run('getKeywordList') }
			{set:$tmpWord = urlencode($item['word']);}
			<a href="{url:/site/search_list/word/$tmpWord}">{$item['word']}</a>
			{/foreach}
		</div>
	</div>
	{echo:Ad::show(1)}

	{viewcontent}

	<div class="help m_10">
		<div class="cont clearfix">
			{foreach:items=Api::run('getHelpCategoryFoot') item=$helpCat}
			<dl>
     			<dt><a href="{url:/site/help_list/id/$helpCat[id]}">{$helpCat['name']}</a></dt>
				{foreach:items=Api::run('getHelpListByCatidAll',array('#cat_id#',$helpCat['id']))}
					<dd><a href="{url:/site/help/id/$item[id]}">{$item['name']}</a></dd>
				{/foreach}
      		</dl>
      		{/foreach}
		</div>
	</div>
	{echo:IFilter::stripSlash($siteConfig->site_footer_code)}
</div>

<script type='text/javascript'>
$(function()
{
	{set:$word = IReq::get('word') ? IFilter::act(IReq::get('word'),'text') : '输入关键字...'}
	$('input:text[name="word"]').val("{$word}");

	$('input:text[name="word"]').bind({
		keyup:function(){autoComplete('{url:/site/autoComplete}','{url:/site/search_list/word/@word@}','{$siteConfig->auto_finish}');}
	});

	var mycartLateCall = new lateCall(200,function(){showCart('{url:/simple/showCart}')});

	//购物车div层
	$('.mycart').hover(
		function(){
			mycartLateCall.start();
		},
		function(){
			mycartLateCall.stop();
			$('#div_mycart').hide('slow');
		}
	);
});

//[ajax]加入购物车
function joinCart_ajax(id,type)
{
	$.getJSON("{url:/simple/joinCart}",{"goods_id":id,"type":type,"random":Math.random()},function(content){
		if(content.isError == false)
		{
			var count = parseInt($('[name="mycart_count"]').html()) + 1;
			$('[name="mycart_count"]').html(count);
			alert(content.message);
		}
		else
		{
			alert(content.message);
		}
	});
}

//列表页加入购物车统一接口
function joinCart_list(id)
{
	$.getJSON('{url:/simple/getProducts}',{"id":id},function(content){
		if(!content)
		{
			joinCart_ajax(id,'goods');
		}
		else
		{
			var url = "{url:/block/goods_list/goods_id/@goods_id@/type/radio/is_products/1}";
			url = url.replace('@goods_id@',id);
			artDialog.open(url,{
				id:'selectProduct',
				title:'选择货品到购物车',
				okVal:'加入购物车',
				ok:function(iframeWin, topWin)
				{
					var goodsList = $(iframeWin.document).find('input[name="id[]"]:checked');

					//添加选中的商品
					if(goodsList.length == 0)
					{
						alert('请选择要加入购物车的商品');
						return false;
					}
					var temp = $.parseJSON(goodsList.attr('data'));

					//执行处理回调
					joinCart_ajax(temp.product_id,'product');
					return true;
				}
			})
		}
	});
}
</script>
</body>
</html>
